<template>
	<view>
        <!-- 公共组件-每个页面必须引入 -->
        <public-module></public-module>
        <wlk-navbar :title="article.name" navbarType='0'></wlk-navbar>
        <view v-if="!loading">
            <view v-if="id>0">
                <u-parse :content="article.content" :selectable="true"></u-parse>
            </view>
            <view class="not-data" v-else>
                <u-empty
                        :icon="uEmpty.data"
                        text="数据为空"
                >
                </u-empty>
            </view>
        </view>
	</view>
</template>

<script>
    import { formatRichText } from '@/wlkutils/tools';
    import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
    import share from "@/wlkutils/share";
	export default {
        computed: {
            ...mapGetters(['themeColor','uEmpty'])
        },
		data() {
			return {
				id:0,
                article:{},
                loading:true
			};
		},
        onLoad(option) {
            if(option.id>0){
                this.id = option.id;
                this.getData();
            }
        },
        onShareAppMessage(res){
            return share.setShareInfo();
        },
        methods: {
            getData() {
                uni.$u.http.post('article/getDetail', {
                    id:this.id
                }).then(res => {
                    this.article = res.data.article;
                    if (!uni.$u.test.isEmpty(this.article.content)) {
                        this.article.content = formatRichText(this.article.content);
                    }
                    this.loading = false;
                }).catch(res => {
                })
            },
        }
	}
</script>

<style lang="scss">
    page{
        background-color: white;
    }
</style>
